package com.qf.dao.impl;

import com.qf.dao.OrderDao;
import com.qf.pojo.Order;
import com.qf.utils.DBTools;
import com.qf.utils.Tools;
import org.apache.commons.dbutils.QueryRunner;

import java.sql.Connection;
import java.sql.SQLException;

public class OrderDaoImpl implements OrderDao {

    QueryRunner qr=new QueryRunner(DBTools.getDataSource());

    @Override
    public int insert(Order order) {
        String sql="INSERT INTO `order` VALUES(?,?,?,?,?,?,?,?)";
        Connection c=DBTools.getConnection();
        try {
            return qr.update(c,sql,order.getOid(),order.getUid(), Tools.format(order.getCreatetime()),
                    order.getTotal(),order.getUname(),order.getAddr(),order.getUtel(),order.getStatus());
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return 0;
    }
}
